package com.m3958.firstgwt.client.datasource;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.m3958.firstgwt.client.constants.DataTemplateFieldConstants;
import com.m3958.firstgwt.shared.type.CommonField;
import com.m3958.firstgwt.shared.type.DataTemplateField;
import com.smartgwt.client.data.fields.DataSourceDateTimeField;
import com.smartgwt.client.data.fields.DataSourceTextField;

@Singleton
public class DataTemplateDataSource extends BaseDataSource{

    public static String className = "com.m3958.firstgwt.server.model.DataTemplate";
    
    @Inject
    public DataTemplateDataSource(DsErrorHandler deh,DataTemplateFieldConstants constants) {
    	
    	setID("datatemplateDS");
    	
        DataSourceDateTimeField updatedAtField = new DataSourceDateTimeField(CommonField.UPDATED_AT.getValue(),constants.updatedAt());
        updatedAtField.setHidden(true);

        addHandleErrorHandler(deh);
        
        DataSourceTextField nameField = new DataSourceTextField(CommonField.NAME.getValue(),constants.name());

        DataSourceTextField tplField = new DataSourceTextField(DataTemplateField.TPL.getValue(),constants.tpl());

        setFields(getIdField(),getVersionField(),getCreatedAtField(false,constants),updatedAtField,nameField,tplField);
        setClientOnly(false);
       
    }

	@Override
	protected String getModelClassName() {
		return className;
	}
}
